<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'registerList.jsp' starting page</title>
    <script type="text/javascript" src="${path}/js/public/grid.js"></script>
    <style type="text/css">
    	.linkActive{color:#ff9900;text-decoration:none;font-weight:bold;}
		.linkNoActive{color:#3399ff;}
    </style>
    <script type="text/javascript">
    
    	$().ready(function(){
    	
    		addCss("0");
    		doQuery("0");
    	});
    
    	//0--待审批 1-已审批
    	var viewArray = ["0","1"];
    	
    	function addCss(id){
    		if(id == "0")
    		{
    			$("#approve").show();
    			$("#history").hide();
    		}else{
    			$("#approve").hide();
    			$("#history").show();
    		}
    		$.each( viewArray, function(n, i){
    			if(i == id){
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkActive");
    			}else {
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkNoActive");
    			}
    		});
    	}
    	
    	function doView(){
    		if(!isSelectOne(mygrid)){
  				alert("请选择一条记录进行审批");
  				return;
  			}
			var record = mygrid.getSelectedRecords()[0];
    		var id = record['id'];
			openDailog("view","${path}/jsp/drug/approveHistory.jsp?id=" + id,500,230,"审批历史",false,true,null);
    	}
    	
    	function doApprove()
		{
    		if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行审批");
  				return;
  			}
    		var id = mygrid.getSelectedRecords()[0].id;
			openDailog("view","${path}/jsp/drug/approveEdit.jsp?id=" + id,500,220,"审批",false,true,null,function(dlg){
				dlg.getIFrame().doSave();
			});
		}
    	
    	var val;
    	function doQuery(status)
  		{
    		val = status;
    		addCss(status);
  			resetGrid(mygrid,"queryForm",{"status":status});
  		}
    	
    	function placeRender(value)
    	{
    		if(value == "0"){
    			return "药房";
    		}else{
    			return "药库";
    		}
    	}
    	
    	function campusRender(value)
    	{
    		if(value == "0"){
    			return "校本部";
    		}else if(value == "1"){
    			return "白云校区";
    		}else if(value == "1"){
    			return "北校区";
    		}else{
    			return "西校区";
    		}
    	}
    	
    	function oprtRender(value,record,columnObj,grid,colNo,rowNo)
  		{
  			return "<a href='javascript:void(0)' style='text-decoration: none;' onclick='showDetails(" + grid.getColumnValue('id',rowNo) + ")'>查看详情</a>";
  		}
    	
    	function showDetails(id){
    		openDailog("view","${path}/jsp/drug/approveDetails.jsp?id=" + id + "&status=" + val,580,400,"审批详细",false,true,null);
    	}
    	
    	function typeRender(value)
    	{
    		if(value == "0"){
    			return "领用";
    		}else if(value == "1"){
    			return "出库";
    		}else if(value == "2"){
    			return "报损";
    		}else if(value == "3"){
    			return "退药";
    		}else if(value == "4"){
    			return "盘点";
    		}
    	}
    </script>
  </head>
  
  <body>
  	<table cellSpacing="0" cellPadding="0" style="width:100%;height:100%;" border="0">
  		<tr>
			<td class="windowTitle"><font size="2">药品管理  &gt; 我的审核</font></td>
		</tr>
  		<tr>
  			<td style="height:35px;width:100%" class="windowHead">	
	  			<form id="queryForm">
					<table cellSpacing="0" cellPadding="0" width="100%" height="100%" border="0" >
						<tr>
							<td width="800" height="20" valign="middle">	
								<img alt="view" src="${path}/images/menu/view.png" height="18px" width="20px" align="top"></img>
								<font style="font-weight:bold;">&nbsp;视图：</font>&nbsp;&nbsp;
								<a href="javascript:doQuery('0')" id="0"><span>待审批</span></a>&nbsp;&nbsp;
								<a href="javascript:doQuery('1')" id="1"><span>已审批</span></a>
							</td>
						</tr>
						<tr>
							<td width="800" height="15" valign="middle">
								<ui:Permission value="approval">
									<ui:Button id="approve" type="save" onclick="doApprove()">审批</ui:Button>
								</ui:Permission>	
								<ui:Permission value="approval_result">
									<ui:Button id="history" onclick="doView()"><img src="${path}/images/drug/approveHistory.png">审批结果</ui:Button>
								</ui:Permission>
							</td>
						</tr>
					</table>
				</form>
				<br/>
				<a style="text-decoration: none;"></a>
			</td>
		</tr>
		
		<tr>
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
				<div id="mess_box" style="width:100%;height:100%;overflow:hidden">
					<ui:Grid id="mygrid" onCellClicked="selectedSingleRow2" 
							 autoLoad="false"
							 parameters='"currentUserId":"${currentUserId }"'
							 dataProvider="com.system.provider.ApproveListProvider:getData" >
						<ui:GridField name="id" header="ID" isChecked="true" align="center" />
			    		<ui:GridField name="user_name" header="申请人" align="center" width="16%" />
			    		<ui:GridField name="type" header="申请类型" align="center" width="16%" render="typeRender"/>
			    		<ui:GridField name="oprt" header="操作" align="center" width="8%" render="oprtRender"/>
			    		<ui:GridField name="place" header="地点" align="center" width="8%" render="placeRender"/>
			    		<ui:GridField name="campus" header="校区" align="center" width="19%" render="campusRender"/>
			    		<ui:GridField name="notes" header="备注" align="center" width="16%" />
			    		<ui:GridField name="create_time" header="申请时间" align="center" width="14%"/>
		    		</ui:Grid>
		    	</div>
		    </td>
		</tr>
  	</table>
  	<script type="text/javascript">
		$().ready(function(){
			disableSelectAll(mygrid);
		});
	</script>
  </body>
</html>
